package com.cskaoyan.market.service;

import com.cskaoyan.market.db.domain.MarketFeedback;
import com.cskaoyan.market.db.domain.MarketFeedbackExample;
import com.cskaoyan.market.db.mapper.MarketFeedbackMapper;
import com.cskaoyan.market.util.MybatisUtils;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author: YaLiFeng
 * @description: TODO
 * @date: 2024/5/8 14:28
 */
public class MarketFeedBackServiceImpl implements MarketFeedBackService {
    @Override
    public List<MarketFeedback> feedBackList(Integer page, Integer limit, String username, String sort, String order, String id) {
        SqlSession session = MybatisUtils.getSession();
        MarketFeedbackMapper marketFeedbackMapper = session.getMapper(MarketFeedbackMapper.class);
        MarketFeedbackExample example = new MarketFeedbackExample();
        example.setOrderByClause(sort + " " + order);
        MarketFeedbackExample.Criteria criteria = example.createCriteria();
        if (!StringUtils.isEmpty(username)) {
            criteria.andUsernameLike("%" + username + "%");
        }
        if (!StringUtils.isEmpty(id)) {
            criteria.andIdEqualTo(Integer.valueOf(id));
        }
        PageHelper.startPage(page, limit);
        criteria.andLogicalDeleted(true);
        List<MarketFeedback> marketFeedbackList=marketFeedbackMapper.selectByExample(example);

        return marketFeedbackList;
    }


}
